<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
		<meta name="format-detection" content="telephone=no">
		<title>{:C('WEB_SITE_TITLE')}</title>
		<link rel="stylesheet" href="__PUBLIC__/Home/css/common.css">
		<link rel="stylesheet" href="__PUBLIC__/Home/css/main.css">
		<script src="__PUBLIC__/Home/js/zepto.js"></script>
		<include file="Public/weixin"/>
		<script src="__PUBLIC__/Home/js/delIOS_huitan.js"></script>
	</head>
	<body class="box">
		<!--提示文字-->
		<div class="tip" style="opacity: 0;z-index: -1"></div>
		<!--正文区域-->
		<div id="dingdanQuerenDanTop" class="topBackTitle">
			<div class="contain maxWidth">
				<a class="hz back" href="javascript:;">&#xe600;</a>确认订单
			</div>
		</div>
		<div id="dingdanQuerenDanMain" class="fastscroll dingdanMain">
			<div class="contain maxWidth">
				<div class="line"></div>
				<a href="/Member/UserAddress?cart_id={$cart_id}" class="top">
					<div class="clear">
						<span class="hz pos">&#xe60d;</span>
						<div class="center">
							<p>收货人: <span>{$useraddress.name}</span></p>
							<p>联系方式: <span>{$useraddress.mobile}</span></p>
							<p>收货地址: <span>{$useraddress.address}</span></p>
						</div>
						<span class="hz jiantou">&#xe60c;</span>
					</div>
				</a>
				<div class="quanzhifu">
					<ul>
						<li class="zhifu">
							<a href="javascript:;">
								<span class="left">支付方式</span>
								<span class="center right zhifu">微信支付</span>
								<span class="hz">&#xe60c;</span>
							</a>
						</li>
						<li>
							<a href="javascript:;">
								<span class="left">配送方式</span>
								<span class="right">送货</span>
							</a>
						</li>
					</ul>
				</div>
				<div class="ddproList">
					<ul class="list">
						<volist name="list" id="item">
						<li class="clear">
							<div class="left">
								<img src="{$item.image}">
							</div>
							<div class="right">
								<p class="title"><a href="{:U('Product/detail',array('id'=>$item['product_id']))}">{$item.title}</a></p>
								<p class="price">
									<em>&yen;{$item.product_price}</em><del>&yen;{$item.market_price}</del><span class="r">&times;<span>{$item.product_num}</span></span>
								</p>
							</div>
						</li>
						</volist>
					</ul>
				</div>
				<if condition="$couponnum gt 0">
				<div class="quanzhifu">
					<ul>
						<li>
							<a href="/Cart/couponlist/cart_id/{$cart_id}">
								<span class="left">优惠券</span>
								<span class="center right">有{$couponnum}张可用优惠券</span>
								<span class="hz">&#xe60c;</span>
							</a>		
						</li>
					</ul>
				</div>
				</if>
				<div class="priceList">
					<ul>
						<li>
							<span class="left">商品金额</span>
							<span class="right">&yen;{$total_price}</span>
						</li>
						<li>
							<span class="left">运费</span>
							<span class="right">+&yen;{$express_money}</span>
						</li>
						<if condition="$coupondetail neq null">
						<li>
							<span class="left">优惠券</span>
							<span class="right">-&yen;{$coupon.money}</span>
						</li>
						</if>
					</ul>
				</div>
			</div>
		</div>
		<div id="dingdanQuerenDanBot" class="dingdanBot">
			<div class="contain maxWidth">
				合计：<span>&yen;<em>{$total_price+$express_money-$coupon.money}</em></span>
				<a href="javascript:addorder()">去支付</a>
			</div>
		</div>
<input type="hidden" id="total_price" value="{$total_price}" />
<input type="hidden" id="express_money" value="{$express_money}" />
<!--送货上门地址ID-->
<input type="hidden" id="address_id" value="{$useraddress.id}" />
<input type="hidden" id="cart_id" value="{$cart_id}" />
<input type="hidden" id="coupon_id" value="{$coupondetail.id}" />

		<script>
			function addorder()
			{
				var cart_ids=$('#cart_id').val();//买了哪几个商品
				var address_id=$('#address_id').val();//送货上门地址ID
				var total_price=$('#total_price').val();//总金额
				var express_money=$('#express_money').val();//运费
				$.ajax({  
					type:'post',  
					traditional :true,  
					url:"{:U('Spellcart/addorder')}",  
					data:{'cart_ids':cart_ids,'address_id':address_id,'total_price':total_price,'express_money':express_money,'coupon_id':$('#coupon_id').val()},  
					success:function(data){
						if(data.status==0)
						{
							tipFun(data.info);
						}
						else
						{
							tipFun('下单成功');
							window.location.href='/Member/spell';
							///wxpay/example/jsapi.php?order_id=3
							//window.location.href='/wxpay/example/jsapi.php?order_id='+data.order_id;
						}
					}  
				});
			}
			//返回按钮
			$('#dingdanQuerenDanTop .back').on('click',function(){
				window.history.go(-1);
			});

			//点击 支付方式
			$('#dingdanQuerenDanMain .quanzhifu .zhifu').on('click',function(){
				var text=$(this).find('.right').text();
				var num=null;
				if(text=='余额支付'){
					num=1;
				}else if(text=='支付宝支付'){
					num=2;
				}else if(text=='微信支付'){
					num=3;
				}
				//location.href='订单确认支付方式.html?zhifuType='+num;
			});

			//获取参数  余额支付1 支付宝支付2 微信支付3
			var hrefstr=location.href;
			if(hrefstr.indexOf('zhifuType=')!=-1){
				var num=hrefstr.substring(hrefstr.indexOf('zhifuType=')+10);
				var text=null;
				if(num==1){
					text='余额支付';
				}else if(num==2){
					text='支付宝支付';
				}else if(num==3){
					text='微信支付';
				}
				$('#dingdanQuerenDanMain .quanzhifu li .zhifu').text(text);
			}

			//根据图片的宽度，确定图片的高度
			window.addEventListener('load',function(){
				var imgw=$('#dingdanQuerenDanMain .ddproList .list .clear .left img').width();
				$('#dingdanQuerenDanMain .ddproList .list .clear .left img').height(imgw);
				$('#dingdanQuerenDanMain .ddproList .list .clear .right').height(imgw);
			},false);

			//tip
			function tipFun(str){
				$('.tip').text(str).css({
					'opacity':'1',
					'z-index':'9999'
				});
				setTimeout(function(){
					$('.tip').css('opacity','0');
					setTimeout(function(){
						$('.tip').css('z-index','-1');
					},300);
				},1300);
			}
		</script>
	</body>
</html>
